All Questions
Tagged with programming-challengec
160 questions
7votes
5answers
2kviews
Solving an easy LeetCode "Merge Strings Alternately"
I am a C++ dev trying to solve problems in C to practice it, specifically the LeetCode Merge Strings Alternately problem: You are given two strings word1 and word2. Merge the strings by adding ...
8votes
2answers
196views
Leetcode 93: Restore IP Addresses (C version)
This is posted in response to this request made in a discussion of my "C-ish" answer to a recent Code Review question regarding a Python solution to a Leetcode challenge. It was reported ...
7votes
3answers
764views
Finding the Zeckendorf Representation of a Positive Integer (BIO 2023 Q1)
I was practicing question 1a of the British Informatics Olympiad 2023 past paper. In the Fibonacci sequence each number is generated by adding the previous two numbers in the sequence. We will start ...
6votes
1answer
376views
String Decryption in C (BIO 2022 Q1)
I was practicing question 1a of the 2022 British Informatics Olympiad past paper. Each letter in the alphabet can be given a value based on its position in the alphabet, A being 1 through to Z being ...
6votes
2answers
448views
Family, felon & fuzz River Crossing challenge
I first saw this challenge when a user posted it to SO about two years ago without a shred of code. The post's plea, "How do I get started?" meant the user's post didn't survive long on that ...
4votes
2answers
308views
Count frequency of words and print them in sorted order
Objective: Write a program to count the frequencies of unique words from standard input, then print them out with their frequencies, ordered most frequent first. For example, given this input: ...
4votes
2answers
129views
Delete a node in binary tree
Problem Statement Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST. Basically, the deletion ...
6votes
2answers
226views
Advent of Code 2023 day 1: Trebuchet (Part 1 and 2) Follow-up
This is a follow-up to the question asked here: Advent of Code 2023 day 1: Trebuchet (Part 1 and 2) Changes made: The code no longer assumes that all lines will fit into a fixed-size buffer. Although ...
4votes
1answer
122views
Advent of Code 2023 day 1: Trebuchet (Part 1 and 2)
Part 1: The task involves analyzing a calibration document containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and ...
2votes
5answers
299views
Sum of bitwise XOR of each subarray weighted by length
here is the problem statement You are given an array a of length n consisting of non-negative integers. You have to calculate the value of \$\sum_{l=1}^n \sum_{r=l}^n f(l,r)\cdot (r - l + 1)\$ where \...
5votes
2answers
152views
Generating Pascal's Triangle in C99
I recently completed the Pascal's Triangle challenge on leetcode. I would like to have my code reviewed. You don't need a leetcode account to see the description of the challenge linked above, but for ...
3votes
3answers
136views
Solution to Codejam 2021 1C (Closest Pick) in C
The following code is my solution to the Closest Pick problem from Codejam 2021. You are entering a raffle for a lifetime supply of pancakes. N tickets have already been sold. Each ticket contains a ...
4votes
3answers
144views
Simple photomosaic generator
I wrote an implementation of Robert Heaton's Programming Exercise for Advanced Beginners #4 (photomosaics) in C99 using the MagickCore library. The full code is as follows: ...
5votes
1answer
92views
Möbius function using iterators for prime factors
While working on Project Euler, I have come across a few questions involving usage of the little omega function, big omega function, and Möbius function. My prior code wrote factors into an array and ...
6votes
1answer
596views
HackerEarth challenge: Lunch boxes
I was solving the lunch boxes problem on HackerEarth but as I submitted my solution most of the test cases were passed and the rest showed 'Time Limit Exceeded'. I would be very grateful if you could ...